package com.prime.tutorial.moviestore.view.techsupport;

import com.prime.tutorial.moviestore.domain.Device;
import com.prime.tutorial.moviestore.service.techsupport.TechSupportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;

/**
 * Responsible for techSupport device removal.
 * Provides the list of devices for the binding with the dataTable from RemoveDevice and
 * provides the link to the service layer of techSupport.
 * @author vasylja
 */

@Component("listDevicesForRemoval")
@Scope("request")
public class ListDevicesForRemoval implements Serializable {
    private TechSupportService techSupportService;
    private List<Device> listDevicesForRemoval;

    @Autowired
    public ListDevicesForRemoval(TechSupportService techSupportService) {
        this.techSupportService = techSupportService;
        setListDevicesForRemoval(this.techSupportService.findDevicesToRemove());
    }

    public List<Device> getListDevicesForRemoval() {
        return listDevicesForRemoval;
    }

    private void setListDevicesForRemoval(List<Device> listDevicesForRemoval) {
        this.listDevicesForRemoval = listDevicesForRemoval;
    }
}
